#include <bits/stdc++.h>

template <typename FwdIter,
          class Comp = std::less<typename std::iterator_traits<FwdIter>
                                 ::value_type>>
void swapMaximum(FwdIter begin, FwdIter end,
                 Comp cmp = Comp()){
    std::iter_swap(max_element(begin, end, cmp), std::prev(end));
}

int main() {
    std::vector<int> a;
    int n;
    std::cin >> n;
    std::copy_n(std::istream_iterator<int>(std::cin), n, std::back_inserter(a));
    if (!a.empty())
        swapMaximum(a.begin(), a.end());
    std::copy(a.begin(), a.end(), std::ostream_iterator<int>(std::cout, " "));
    std::cout << std::endl;
};
